# -*- encoding:utf-8 -*-
# __author__ = 'chenyongbing'
# __poject__ = 'ops_platform'
# __datetime__ = '2022/7/29'
# __name__ = 'signer_helper.py'
from itsdangerous.url_safe import URLSafeSerializer

# Create your code here.

class Signer(URLSafeSerializer):
    def sign(self, value):
        newvalue = self.dumps(value)
        return newvalue

    def unsign(self, value):
        try:
            newvalue = self.loads(value)
            return newvalue
        except:
            return value
    
if __name__ == '__main__':
    signer = Signer('django-insecure-sm6q**s%(4^y8x@@fqz__!q)iqjm^@hy7q+44xb&8s)t4yz_nb')
    encoded = signer.sign('xxx')
    decoded = signer.unsign('encoded')
    print(encoded, decoded)